package cn.itlaobing.web.model;

import java.util.List;

public class PaginatoinModel<T> {
    public static final Integer EVERY_SIZE=3;
    private List<T> listModels;
    //每页显示的行数
    private Integer size=EVERY_SIZE;
    //总行数
    private Integer totalsize;
    //当前页
    private Integer thisPage;
    //总页数
    public Integer getTotalPages(){
        return totalsize%size==0?totalsize/size:totalsize/size+1;
    }
    //是否有上一页
    public boolean isHasPrevious(){
        return thisPage>1;
    }
    //是否有下一页
    public boolean isHasNext(){
        return thisPage<getTotalPages();
    }
    //上一页
    public Integer getPrevious(){
        if(isHasPrevious()){
            return thisPage-1;
        }
        return 1;
    }
    //下一页
    public Integer getNext(){
        if(isHasNext()){
            return thisPage+1;
        }
        return getTotalPages();
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getTotalsize() {
        return totalsize;
    }

    public void setTotalsize(Integer totalsize) {
        this.totalsize = totalsize;
    }

    public Integer getThisPage() {
        return thisPage;
    }

    public void setThisPage(Integer thisPage) {
        this.thisPage = thisPage;
    }

    public List<T> getListModels() {
        return listModels;
    }

    public void setListModels(List<T> listModels) {
        this.listModels = listModels;
    }
}
